/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.servicesnpayroll.bl;

import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import mx.servicesnpayroll.dao.EmpleadoFacadeLocal;
import mx.servicesnpayroll.model.Empleado;

/**
 *
 * @author Grnmnd
 */
@Stateless
public class EmpleadoBL implements EmpleadoBLLocal {
    @EJB
    private EmpleadoFacadeLocal empleadoFacade;
    
    
    @Override
    public void create(Empleado em) {
        empleadoFacade.create(em);
    }

    @Override
    public void edit(Empleado em) {
        empleadoFacade.edit(em);
    }

    @Override
    public void remove(Empleado em) {
        em.setEliminado(true);
        empleadoFacade.edit(em);
    }

    @Override
    public List<Empleado> findAll() {
        List<Empleado> all=new ArrayList<Empleado>();
        for(Empleado e:empleadoFacade.findAll()){
            if(!e.getEliminado()){
                all.add(e);
            }
        }
        return all;
    }

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

    @Override
    public Empleado find(Object id) {
        return empleadoFacade.find(id);
    }

}
